package Demo20;

import java.io.InputStream;
import java.net.URL;

public class URLTest {
//    URL类【读取网上资源】
//    public static class  URLTest{
    public static void main(String[] args)  throws  Exception{
        URL url =new URL("http://www.scitc.com.cn");
//        URL url =new URL("http://www.sohu.com");
//        URL url =new URL("http://www.263.net");
        //有网站具有反爬功能
//        InputStream--字节流
        InputStream is=url.openStream();
        int n=-1;
//        byte[] 字节数组
        byte[] bs=new byte[1024];
        while ((n=is.read(bs))!=-1){
            System.out.println(new String(bs,0,n,"UTF-8"));
        }
        is.close();

    }

}
//}
